/*
 * Copyright (c) 2015, the Dart project authors.
 *
 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package vm.element

// This file is generated by the script: pkg/vm_service/tool/generate.dart in dart-lang/sdk.

import com.google.gson.JsonArray
import com.google.gson.JsonObject

/**
 * {@link Library} 提供有关 Dart 语言库的信息。
 */
class Library(json: JsonObject) : Obj(json) {

    /**
     * 此库中所有类的列表。
     */
    fun getClasses(): ElementList<ClassRef> {
        return object : ElementList<ClassRef>(json.get("classes").asJsonArray) {
            override fun basicGet(array: JsonArray, index: Int): ClassRef {
                return ClassRef(array.get(index).asJsonObject)
            }
        }
    }

    /**
     * 这个库是否可调试？默认为 true。
     */
    fun getDebuggable(): Boolean {
        return getAsBoolean("debuggable")
    }

    /**
     * 此库的导入列表。
     */
    fun getDependencies(): ElementList<LibraryDependency> {
        return object : ElementList<LibraryDependency>(json.get("dependencies").asJsonArray) {
            override fun basicGet(array: JsonArray, index: Int): LibraryDependency {
                return LibraryDependency(array.get(index).asJsonObject)
            }
        }
    }

    /**
     * 此库中顶级函数的列表。
     */
    fun getFunctions(): ElementList<FuncRef> {
        return object : ElementList<FuncRef>(json.get("functions").asJsonArray) {
            override fun basicGet(array: JsonArray, index: Int): FuncRef {
                return FuncRef(array.get(index).asJsonObject)
            }
        }
    }

    /**
     * 此库的名称。
     */
    fun getName(): String? {
        return getAsString("name")
    }

    /**
     * 构成此库的脚本列表。
     */
    fun getScripts(): ElementList<ScriptRef> {
        return object : ElementList<ScriptRef>(json.get("scripts").asJsonArray) {
            override fun basicGet(array: JsonArray, index: Int): ScriptRef {
                return ScriptRef(array.get(index).asJsonObject)
            }
        }
    }

    /**
     * 此库的 URI。
     */
    fun getUri(): String? {
        return getAsString("uri")
    }

    /**
     * 此库中顶级变量的列表。
     */
    fun getVariables(): ElementList<FieldRef> {
        return object : ElementList<FieldRef>(json.get("variables").asJsonArray) {
            override fun basicGet(array: JsonArray, index: Int): FieldRef {
                return FieldRef(array.get(index).asJsonObject)
            }
        }
    }
}
